package helloworld.admin.action.center;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import helloworld.admin.bean.CenterAdminBean;
import helloworld.admin.form.center.*;
import helloworld.delegate.center.CenterListDelegate;

/**
 *
 * @author TUYEN-DM
 * @version $Revision:   $ $Date:20090424   $
 */
public class CenterSearchAction extends Action{
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		
		ActionForward forward = null;
		
		CenterSearchForm searchform = (CenterSearchForm)form;
		
		if((searchform.getSearchButton().isSelected()) || ("Search".equals(request.getParameter("action")))) {
			CenterListDelegate delegate = new CenterListDelegate();
			CenterAdminBean[] customers = delegate.findCenters(searchform.getCenterName());
			request.setAttribute("CENTER_DETAIL_OBJECTS", customers);
			forward = mapping.findForward("success");
		}
		
		return forward;		
	}

}
